Get previous value in Post Trigger (prevent selection)

Hello!

I want to set back an enumeration value to the old value (obj.selectedAttribute=oldValue) if a condition is fulfilled.

My question:

How do i get the old value to set it back when a if-clause fails?

string DXLCode2 = "
    Trigger    trg = current;           
    if (null trg) halt();
    AttrDef ad  = attrdef(trg);
    if (null ad) halt();  // Error?
    Object  obj = object(trg);  
    if (null obj) halt();  // Error?
    string  Name = ad.name;   
    
    Module mod = module(trg);
    
    // Trigger feuert auch im read mode, wenn
    // man das Objekt doppelklickt, daher...
    if(!isEdit(mod)&&!isShare(mod)) halt();

    string oldValue=????

    string newValue=????

    if(oldValue=="hallo"&&newValue=="Tag")
    {
        obj.selectedAttribute=oldValue;
    }
 
    }
";

void installVarCoTriggersWithoutConfirmation()
{

    Trigger trg2;
    bool    TrigOK2 = true;
    string  ErrMess2 = checkDXL(DXLCode2);
    string  NameTrig2 = "PostEditTrigger";
      
    if (!null ErrMess2)
    {
       TrigOK2       = false;
    }
      
    ErrMess2 = delete (NameTrig2, module->object->attribute, post, modify, 7);
        
    if (TrigOK2)
    {
       trg2     = trigger(NameTrig2, module->object->attribute, post, modify, 7, DXLCode2);
    }

}

 


Bjoern_Karpenstein - Wed Nov 18 09:27:25 EST 2015

Re: Get previous value in Post Trigger (prevent selection)
Mathias Mamsch - Thu Nov 19 03:12:13 EST 2015

I think your are looking for a "pre" modification trigger. This trigger will give you not only the change to read the value about to be written, but also prevent the modification ( set(trigPreConFail) ). Check the DXL manual for details. Regards, Mathias

Re: Get previous value in Post Trigger (prevent selection)
Bjoern_Karpenstein - Tue Apr 12 02:37:34 EDT 2016

Mathias Mamsch - Thu Nov 19 03:12:13 EST 2015

I think your are looking for a "pre" modification trigger. This trigger will give you not only the change to read the value about to be written, but also prevent the modification ( set(trigPreConFail) ). Check the DXL manual for details. Regards, Mathias

Hi Mathias,,

Your suggestion would work pretty if i would get the value, to what it has been changed. I can get the new value in the post-modify-trigger, but there i do not get the previous value.

I use this pre-Trigger

Trigger trg    = trigger("ModifyTrigger", module->object->attribute, pre, modify, 6, "TRIGGER CODE");

My problem is, that i can only get the enumeration value before it has been changed, although the UI already shows the new one. In the attribute-pre-modify-trigger i am using the following declarations to get information:

Trigger    trg = current;           
if (null trg) halt(); 
AttrDef ad  = attrdef(trg); 
if (null ad) halt();  // Error?
Object  obj = object(trg);  
if (null obj) halt();  // Error?
string  Name = ad.name;   

In (and only in) pre-Triggers you can cancel the edit event with

set(trigPreConFail); halt;

To cancel the edit event means, that it will be set back to the old value, what is exactly what i want.

I.e. when i change the enumeration from A to B, the variable "obj.Name" in the pre-modify-trigger contains A. But i have to ask for B

if(B=="released) then set back to A

 

 

(Setting back means calling set(trigPreConFail) what is only available in pre-Triggers). How can i get the value B? The UI shows it.

 

 

 

1.) In Attribute Post Modify Trigger obj.Name contains B

2.) In Attribute Pre Modify Trigger obj.Name contains A, but i have to ask for be to set it back with set(trigPreConFail)

 

Can someone help me? :/

 

With best regards,

Bjoern

Re: Get previous value in Post Trigger (prevent selection)
Mathias Mamsch - Tue Apr 12 03:04:06 EDT 2016

Bjoern_Karpenstein - Tue Apr 12 02:37:34 EDT 2016

Hi Mathias,,

Your suggestion would work pretty if i would get the value, to what it has been changed. I can get the new value in the post-modify-trigger, but there i do not get the previous value.

I use this pre-Trigger

Trigger trg    = trigger("ModifyTrigger", module->object->attribute, pre, modify, 6, "TRIGGER CODE");

My problem is, that i can only get the enumeration value before it has been changed, although the UI already shows the new one. In the attribute-pre-modify-trigger i am using the following declarations to get information:

Trigger    trg = current;           
if (null trg) halt(); 
AttrDef ad  = attrdef(trg); 
if (null ad) halt();  // Error?
Object  obj = object(trg);  
if (null obj) halt();  // Error?
string  Name = ad.name;   

In (and only in) pre-Triggers you can cancel the edit event with

set(trigPreConFail); halt;

To cancel the edit event means, that it will be set back to the old value, what is exactly what i want.

I.e. when i change the enumeration from A to B, the variable "obj.Name" in the pre-modify-trigger contains A. But i have to ask for B

if(B=="released) then set back to A

 

 

(Setting back means calling set(trigPreConFail) what is only available in pre-Triggers). How can i get the value B? The UI shows it.

 

 

 

1.) In Attribute Post Modify Trigger obj.Name contains B

2.) In Attribute Pre Modify Trigger obj.Name contains A, but i have to ask for be to set it back with set(trigPreConFail)

 

Can someone help me? :/

 

With best regards,

Bjoern

You can get the "new" value from the trigger ... I think its "Trigger T = current; Buffer buf = create(); value(T, buf);" or something like this. Regards, Mathias

Re: Get previous value in Post Trigger (prevent selection)
Bjoern_Karpenstein - Tue Apr 12 03:29:52 EDT 2016

Mathias Mamsch - Tue Apr 12 03:04:06 EDT 2016

You can get the "new" value from the trigger ... I think its "Trigger T = current; Buffer buf = create(); value(T, buf);" or something like this. Regards, Mathias

Thank you very much i made some very dirty things with the History in the post triggers before :/